﻿using System;

namespace MiserBlogHelper.Helper
{
    public class TimeHelper
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="time1"></param>
        /// <param name="time2"></param>
        /// <returns>-2:表示参数time2 不是时间</returns>
        public static int CompareTo(DateTime time1, string time2)
        {
            DateTime t2 = ParseTime(time2);
            if (t2 != DateTime.MinValue)
            {


                return time1.CompareTo(t2);
            }
            return -2;
        }

        public static DateTime ParseTime(string timeStr)
        {
            DateTime time;
            if (DateTime.TryParse(timeStr, out time))
            {
                return time;
            }
            return DateTime.MinValue;
        }
    }
}
